<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title><fmt:message key="userCompanyDetail.heading"/></title>

    <script type="text/javascript">
    
	$(function() {
		applyDate("datepicker");

	});
	</script>
    <SCRIPT src="${ctxPath}/style/superValidator.js" type=text/javascript></SCRIPT>
	<SCRIPT type=text/javascript>
	$(document).ready(function(){
	setEmptyCheck("username:password:rePassword:address:fullname");	
	setIntegeCheck("memberCard");
	setMailCheck("email");
	setIntegeCheck("sex");
	setIDCheck("idCard");
	setMobileCheck("mobile");
	
	});
	
	function comparePwd(obj)
	{
		var pwd=document.getElementById("password").value;
		if(obj.value!=pwd)
		{
			obj.value="";
		}
	}
	
	function validateUserName(){
   	 var userName=$("#username").val();
   	 if(userName==""){
   		 return;
   	 }
		$.ajax({
			 type: "post",
			  url:__ctxPath+"/member/user/userCommon.do?cmd=validateUserName",
			  data:{userName:userName},
			  async:false,
			  success:function(valicode){
				  var showText="";
				  $("#showText").empty();
				  if(valicode=='true'){
					  showText='恭喜您!账号可以使用';
				  }else{
					  showText='<font color="red">账号已使用 ,请重新填写</font>';
					  $("#username").val('');
				  }
				  $("#showText").append(showText);
			  },
			  error:function(XMLHttpRequest){
				  $("#username").val('');
				  $("#showText").append('<font color="red">获取请求错误!</font>');
				  }
		});
    }
</SCRIPT>

  </head>
  <body>
   

<form:form method="post" id="user" commandName="user" action="editUser.do">	
<form:hidden path="userId"/>

<ul>
	  <li class="titleonly"><img src="${ctxPath}/image/dot.gif" width="15" height="16" class="dot" />&gt;&gt;添加会员信息<a href="${ctxPath}/admin/system/users.do"><img src="${ctxPath}/image/backtrack.gif" width="14" height="14" align="absmiddle" class="backtrack"/>返回</a></li>
	</ul>
	<ul>
	
<%-- 	<li class="listgrey">会员卡号
	    <input name="memberCard" type="text" class="inputbox190" id=memberCard check=2 tip="只支持数字" value="${user.memberCard }" />
	  </li> --%>
	
	  <li class="listwhile">登陆账号
	  
	    <input name="username" ${user.userId==null?"":"readonly='readonly'" } type="text"  ${user.userId!=null?"":"onblur='validateUserName()'" } class="inputbox120" id=username check=2 tip="不能为空" value="${user.username }" /><span id="showText"></span>
	    
	  </li>
	  <li class="listgrey">账号密码
	    <input type="password" name="password" class="inputbox120" id=password check=2  tip="不能为空" value="${user.password }" />
	  </li>
	  <li class="listwhile">确认密码
	    <input type="password" class="inputbox120" id=rePassword check=2  tip="不能为空" onBlur="comparePwd(this)" value="${user.password }" />
	  </li>
	  <li class="listgrey">电子邮件
	    <input name="email" type="text" class="inputbox240" id=email check=2 tip="输入正确电子邮箱"  value="${user.email }" />
	  </li>
	  <li class="listwhile"></li>
	  <li class="listgrey">真实姓名
	    <input name="fullname" type="text" class="inputbox85" id=fullname check=2  tip="不能为空"   value="${user.fullname }"/>
	  </li>
	  <li class="listwhile">性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别
	    <select name="sex" id="sex" class="inputbox40">
		  	    <option value="1">男</option>
				<option value="2">女</option>
		</select>
		<script type="text/javascript">
		 if("${user.sex}"!="")
		 {
			 document.getElementById("sex").value="${user.sex}";
		 }
		 
		 </script> 
	  </li>
	  <li class="listgrey">生&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;日
	    <input name="birthday" type="text" class="inputbox85" id="datepicker" value="${user.birthday }"/>
	  </li>
	  
	  <li class="listgrey">身份证号
	    <input name="idCard" type="text" class="inputbox190" id=idCard check=2 tip="输入正确身份证" value="${user.idCard }" />
	  </li>
	  
	  <li class="listwhile">固定电话
	    <input name="phone" type="text" class="inputbox120" id=phone value="${user.phone }"/><font color="#6666FF"> (固话手机可二选一填写)</font>
	  </li>
	  <li class="listgrey">手&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;机
	    <input name="mobile" type="text" class="inputbox120" id=mobile check=2 tip="输入正确手机号" value="${user.mobile }" />
	  </li>
	  
	  <li class="listwhile">联系地址
	    <input name="address" type="text" class="inputbox300" id=address check=2 tip="不能为空" value="${user.address }" />
	  </li>
	  
	  <li class="listgrey">邮政编码
	    <input name="postCode" type="text" class="inputbox85" value="${user.postCode }" />
	  </li>
	  

	  <li class="listwhile"></li>
	  <li class="listgrey">
		<input type="hidden" name="userType" value="1">
		<input type="hidden" name="status" value="1">
	    <input name="submit" type="submit" onClick="bCancel=false" value=" 保存 " class="inputsubmit"/>
		&nbsp;
		<input name="cancel" type="submit" onClick="bCancel=true" value=" 取消 " class="inputsubmit" />
	  </li>
	</ul>
						
					</form:form>	
  </body>
</html>